package os_env

import (
	"fmt"
	logger "gitee.com/zaper/private-logger"
	"gitee.com/zaper/software-framework/constant"
	"os"
	"strconv"
)

const (
	NginxDomainKey      = "route-service"
	NginxDomainValue    = "route-service.comb.com"
	ResisterCenterKey   = "ResisterCenterDns"
	ResisterCenterValue = "service-center.comb.com"
)

const (
	ServiceNameKey    = "serviceName"
	ServiceNameValue  = "service-center"
	AppNameSpaceKey   = "NameSpace"
	AppNameSpaceValue = "SoftWareSign"
	ServiceIdKey      = "serviceId"
)

var (
	ServiceId = fmt.Sprintf("%s-%d", ServiceNameValue, 0)
)

func InitializeEnv() {
	if err := os.Setenv(AppNameSpaceKey, AppNameSpaceValue); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
	if err := os.Setenv(NginxDomainKey, NginxDomainValue); err != nil {
		logger.Errorf("set NginxWorkspace env fail, err is %s", err)
	}
	if err := os.Setenv(ServiceNameKey, ServiceNameValue); err != nil {
		logger.Errorf("set ServiceNameKey env fail, err is %s", err)
	}
	if err := os.Setenv(ResisterCenterKey, ResisterCenterValue); err != nil {
		logger.Errorf("set NginxWorkspace env fail, err is %s", err)
	}
	if err := os.Setenv(ServiceIdKey, ServiceId); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
	if err := os.Setenv(constant.SslPath, "F:/project/go/service-center/src/cert/"); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
	if err := os.Setenv(constant.SslPwd, "123456789"); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
	if err := os.Setenv(constant.TlsMode, strconv.Itoa(constant.Oneway)); err != nil {
		logger.Errorf("set AppNameSpaceKey env fail, err is %s", err)
	}
}
